perm filename MAPTST.PAL[HAL,HE]2 blob sn#184721 filedate 1975-11-05 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00006 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	 This is a test program to try out some ideas about the
C00003 00003	  Map definitions
C00006 00004	  COMMON, PINIT, TOSPC
C00008 00005	  DRIVER
C00010 00006	.END
C00015 ENDMK
C⊗;
COMMENT ⊗ This is a test program to try out some ideas about the
glorious Panofsky map.  ⊗
;  Map definitions

;Page tables
PTAB0 = 166000		;100 words, 1 per page
PTAB1 = 166200		;100 words, 1 per page
PTAB2 = 166400		;100 words, 1 per page
PTAB3 = 166600		;100 words, 1 per page

;Page table entries (each one for 2000 bytes)
WRINTO == 100000	;Page has been written into
ACCESD ==  40000	;Page has been accessed
WRPERM ==  20000	;Page may be written into
RDPERM ==  10000	;Page may be read from
UNIBIT ==   4000	;on => unibus only.  off => fastbus only
PHSPAG ==   3777	;high order address bits of physical page

;Map space table
KISPCE = 167020		;Kernel I space
KDSPCE = 167030		;Kernel D space
SISPCE = 167022		;Supervisor I space
SDSPCE = 167032		;Supervisor D space
NUSPCE = 167024		;Unused I space
NUSPCE = 167034		;Unused D space
UISPCE = 167026		;User I space
UDSPCE = 167036		;User D space

;Map space table entries
PTABNO == 1400		;The page table (0:3) to use for this space
TRANSP ==  200		;1 => no mapping
MXVRPG ==  176		;Maximum page that may be referenced

;Status registers
STATR0 = 167000		;Status register 0
	MAPENB == 100000	;1 => enable mapping


;  COMMON, PINIT, TOSPC

.=1000
.INSRT HALHED[HAL,HE]

COMMON:
Comment ⊗ Takes the page table start address in R0 (PTAB0:PTAB3).
Sets virtual memory 0-17777 and 120000-177777 to the equivalent
physical memory.  ⊗
	MOV R2,-(SP)	;Save R2
	MOV #UNIBIT+WRPERM+RDPERM,R1	;Page table entry
	MOV #70,R2	;Number of entries for low common page table
COM1:	MOV R1,(R0)+	;Put in the entry
	SOB R2,COM1	;Repeat

	MOV #UNIBIT+WRPERM+RDPERM+370,R1	;page 370 (phys. add. 760000)
	MOV #10,R2	;Number of entries for high common page table
COM3:	MOV R1,(R0)+	;Put in the entry
	INC R1		;Set for next physical page
	SOB R2,COM3	;Repeat

	MOV (SP)+,R2	;Restore R2
	RTS PC		;Done

PINIT:
;  Set up the four page tables

	MOV #PTAB0,R0	;Clear all page table entries to start with
	MOV #400,R1	;
PINI0:	CLR (R0)+	;
	SOB R1,PINI0	;

	;Page table 0
	MOV #PTAB0,R0	;
	JSR PC,COMMON	;
	MOV #PTAB1,R0	;
	JSR PC,COMMON	;
	MOV #PTAB2,R0	;
	JSR PC,COMMON	;
	MOV #PTAB3,R0	;
	JSR PC,COMMON	;

	RTS PC		;Done with PINIT

	;turn it all on, hope it works.
ENABLE:	;Takes the max page code in R0
	MOV R0,KISPCE	;
	MOV R0,KDSPCE	;
	MOV R0,SISPCE	;
	MOV R0,SDSPCE	;
	MOV R0,UISPCE	;
	MOV R0,UDSPCE	;
	MOV #MAPENB,STATR0	;Turns it on.
	RTS PC		;Done

;  DRIVER

MAXP2:	.BLKW 1
PATCH:	.BLKW 100	;Patch area
STACK:	.WORD 100	;Stack
STACE:	.WORD 0		;end of stack
DRIVER:
	MOV #STACE,SP	;Initialize stack
	CLR MAXP2	;Start with 0 max page
	JSR PC,PINIT	;
	MOV #100,R2	;R2 ← Count of how many pages to try
LOOP:	MOV MAXP2,R0	;R0 ← max page currently allowed
	ASL R0		;Put in usual format
	JSR PC,ENABLE	;turns on the mapping with this max page
	MOV MAXP2,R0	;
	INC R0		;
	ASH 10,R0	;Makes an address in the max page + 1
	TST (R0)	;Try it out
	INC MAXP2	;
	SOB R2,LOOP	;Again.
	JMP DDT		;
	
TRP:
.=250
	TRP
	352	;Processor status word
.=TRP
	BIC #100000,STATR0	;Clear mapping
	JMP DRIVER	;
.END